# install.packages("xfun") #uncomment if need to install xfun
# see instructions on naming conventions in Table01.R

xfun::pkg_attach2(c("readxl", "dplyr","haven","stargazer","writexl","lmridge"))
load("Table01.RData")

mboth.econFINAL <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.econ.b, scaling = "sc", K = 2.27576)
mboth.civFINAL <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.civ.b, scaling = "sc", K = 2.82527)
mboth.energyFINAL <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.energy.b, scaling = "sc", K = 3.92577)
mboth.immigrationFINAL <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.imm.b, scaling = "sc", K = 4.41655)
mboth.welfareFINAL <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.wel.b, scaling = "sc", K = 1.78701)
mboth.foreignFINAL.M <- lmridge(abd_d ~ contact + cooperation + d_congress + poly(year, 2), data = mydata.foreign.b.m, scaling = "sc", K = 5.98371)

summary(mboth.econFINAL)
summary(mboth.civFINAL)
summary(mboth.energyFINAL)
summary(mboth.immigrationFINAL)
summary(mboth.welfareFINAL)
summary(mboth.foreignFINAL.M)

mresponse.econFINAL <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.econ.r, scaling = "sc", K = 3.31079)
mresponse.civFINAL <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.civ.r, scaling = "sc", K = 2.32585)
mresponse.energyFINAL <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.energy.r, scaling = "sc", K = 5.07074)
mresponse.immigrationFINAL <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.imm.r, scaling = "sc", K = 4.71462)
mresponse.welfareFINAL <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.wel.r, scaling = "sc", K = 3.04612)
mresponse.foreignFINAL.M <- lmridge(abd_d ~ response + d_congress + poly(year, 2), data = mydata.foreign.r.m, scaling = "sc", K = 8.00626)

summary(mresponse.econFINAL)
summary(mresponse.civFINAL)
summary(mresponse.energyFINAL)
summary(mresponse.immigrationFINAL)
summary(mresponse.welfareFINAL)
summary(mresponse.foreignFINAL.M)